function sendMsg() {
	var inputMsg = document.getElementById('chatInput').value;
	var submitUrl = "AjaxServlet?msg=" + inputMsg;
	postXmlHttp(submitUrl, 'showMsg()');
}

function showMsg() {
	var MsgB = document.getElementById('chatShow');
	var inputMsg = document.getElementById('chatInput');
	var Response = _xmlHttpRequestObj.responseText;
	MsgB.value += "\nME:" + inputMsg.value + "\n"
	+ "Robot:" + Response;
	document.getElementById('chatInput').value = "";
}


var _postXmlHttpProcessPostChangeCallBack;
var _xmlHttpRequestObj;

function postXmlHttp(submitUrl, callbackFunc)
{
	_postXmlHttpProcessPostChangeCallBack = callbackFunc;
	
	if (window.XMLHttpRequest) {
		_xmlHttpRequestObj = new XMLHttpRequest();
		_xmlHttpRequestObj.open('POST', submitUrl, true);
		_xmlHttpRequestObj.onreadystatechange = postXmlHttpProcessPostChange;
		_xmlHttpRequestObj.send();
	} else if(window.ActiveXObject) {
	    _xmlHttpRequestObj=new ActiveXObject("Microsoft.XMLHTTP");
	    _xmlHttpRequestObj.open('POST',submitUrl,true);
	    _xmlHttpRequestObj.onreadystatechange=postXmlHttpProcessPostChange;
	    _xmlHttpRequestObj.send();
	}
}

function postXmlHttpProcessPostChange( )
{
  if( _xmlHttpRequestObj.readyState==4 && _xmlHttpRequestObj.status==200 )
  {
    setTimeout( _postXmlHttpProcessPostChangeCallBack, 2 );
  }
}